package cmd

import (
	"fmt"
	"im-tools/internal/service"

	"github.com/gookit/color"
	"github.com/spf13/cobra"
)

var friendAddCmd = &cobra.Command{
	Use:   "addFriend",
	Short: "加好友",
	Long:  `每次添加一个好友`,
	Run: func(cmd *cobra.Command, args []string) {
		var ownerUid string
		var friendUid string
		for {
			color.Info.Println("输入用户ID:")
			if _, err := fmt.Scanln(&ownerUid); err != nil {
				continue
			}

			color.Info.Println("输入好友ID:")
			if _, err := fmt.Scanln(&friendUid); err != nil {
				continue
			}

			if ownerUid != "" || friendUid != "" {
				break
			}

			fs := service.FriendService{}
			fs.AddOneFriend(ownerUid, friendUid)
			color.Info.Println("添加好友成功")
		}
	},
}

func init() {
	rootCmd.AddCommand(friendAddCmd)
}
